<template>
	<view class="box">
		<index v-if="pageCur == 'index'"></index>
		<login v-if="pageCur == 'login' && hasLogin == false" @func="getMsgFromSon"></login>
		<myinfo v-if="pageCur == 'login' && hasLogin == true"></myinfo>
		<release v-if="pageCur == 'release' && hasLogin == true"></release>
		<bgm v-if="pageCur == 'bgm' && hasLogin == true"></bgm>
		<needLogin v-if="pageCur == 'release' && hasLogin == false"></needLogin>
		<needLogin v-if="pageCur == 'xiaoxi' && hasLogin == false"></needLogin>
		<needLogin v-if="pageCur == 'focus' && hasLogin == false"></needLogin>
		
		<view class="cu-bar tabbar bg-white shadow foot">
			<view class="action " :class="pageCur=='index'? 'text-blue' : 'text-grey' " data-cur="index" @click="NavChanges">
				<view class="iconfont icon-shouye"></view> 首页
			</view>
			
			<view class="action " :class="pageCur=='focus'? 'text-blue' : 'text-grey' " data-cur="focus" @click="NavChanges">
				<view class="iconfont icon-xiazai11"></view> 关注
			</view>
			<view class="action  add-action" :class="pageCur=='release'? 'text-blue' : 'text-grey' " data-cur="release" @click="NavChanges">
				<button class="cu-btn cuIcon-add bg-green shadow"></button>
				发布
			</view>
			<view class="action " :class="pageCur=='xiaoxi'? 'text-blue' : 'text-grey' " data-cur="xiaoxi" @click="NavChanges">
				<view class="iconfont icon-haoyou">
				</view>
				消息
			</view>
			<view class="action " :class="pageCur=='login'? 'text-blue' : 'text-grey' " data-cur="login" @click="NavChanges">
				<view class="iconfont icon-My">
				</view>
				我的
			</view>
		</view>
	</view>
</template>

<script>
	import {
		mapState
	}from 'vuex'
	export default {
		computed:{
			...mapState(['hasLogin','pageCur','userInfo'])
		},
		data() {
			return {
				tabbar:true,
				windowHeight:''
			}
		},	
		
		onLoad: function(option) {
			console.log("当前页面是："+this.pageCur)
			console.log("home页面加载完毕");
			uni.getSystemInfo({
				success: (res) => {
					this.windowHeight = res.windowHeight;
				}
			});
			uni.onWindowResize(function(res){
				if(res.size.windowHeight < this.windowHeight){
					this.tabbar = false
				}else{
					this.tabbar = true
				}
			})
		},
		methods: {
			NavChanges: function(e) {
				var now = e.currentTarget.dataset.cur
				this.$store.dispatch('NavChanges',now)
				console.log(this.pageCur)
			},
			getMsgFromSon(data){
				this.tabbar = data
			}
		}
		
	}
</script>

<style lang="stylus">

</style>
